﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class JobPositionBL
	{

		#region ***** Init Methods ***** 
		JobPositionDA objJobPositionDA;
		public JobPositionBL()
		{
			objJobPositionDA = new JobPositionDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get JobPosition by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>JobPosition</returns>
		public JobPosition GetByID(int id)
		{
			return objJobPositionDA.GetByID(id);
		}

		/// <summary>
		/// Get all of JobPosition
		/// </summary>
		/// <returns>List<<JobPosition>></returns>
		public List<JobPosition> GetList()
		{
			string cacheName = "lstJobPosition";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objJobPositionDA.GetList(), "JobPosition");
			}
			return (List<JobPosition>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of JobPosition
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsJobPosition";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objJobPositionDA.GetDataSet(), "JobPosition");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of JobPosition paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<JobPosition>></returns>
		public List<JobPosition> GetListPaged(int recperpage, int pageindex)
		{
			return objJobPositionDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of JobPosition paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objJobPositionDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new JobPosition within JobPosition database table
		/// </summary>
		/// <param name="obj_jobposition">JobPosition</param>
		/// <returns>key of table</returns>
		public int Add(JobPosition obj_jobposition)
		{
			ServerCache.Remove("JobPosition", true);
			return objJobPositionDA.Add(obj_jobposition);
		}

		/// <summary>
		/// updates the specified JobPosition
		/// </summary>
		/// <param name="obj_jobposition">JobPosition</param>
		/// <returns></returns>
		public void Update(JobPosition obj_jobposition)
		{
			ServerCache.Remove("JobPosition", true);
			objJobPositionDA.Update(obj_jobposition);
		}

		/// <summary>
		/// Delete the specified JobPosition
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("JobPosition", true);
			objJobPositionDA.Delete(id);
		}
		#endregion
	}
}
